import json
import re
import requests


url = 'https://image.baidu.com/aigc/inspirepics?pn=20&rn=20'
response = requests.get(url)
datas = response.json()['inspiration']['inspirations']

img = {}
for data in datas:
    img_url = data['img']
    img_name_s = data['description']
    img_name = re.sub(r'[，： 。,]', '', img_name_s)
    # print(img_url, img_name)
    with open(f'../Static/imanges/百度图片/{img_name}.webp', 'wb') as f:
        f.write(requests.get(img_url).content)


# http://gips3.baidu.com/it/u=3886271102,3123389489/u0026fm=3028/u0026app=3028/u0026f=JPEG/u0026fmt=auto?w=1280\u0026h=960  加密地址
# http://gips3.baidu.com/it/u=3886271102,3123389489&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960             实际地址

